package cn.xianshu.context;


import cn.xianshu.domain.Login;
import com.alibaba.fastjson.JSON;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class LoginContextHandel {

    public static Login getLogin(){
        try {
            Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
            String jsonUser = authentication.getPrincipal().toString();
            return JSON.parseObject(jsonUser, Login.class);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

}
